
"""
Created on Tue Feb 19 14:55:43 2013

@author: aponteeduarddo@gmail.com
Copyright Eduardo Aponte 2013.
"""

from mex_binder import binder_py

mx_eyelink_current_mode = binder_py('mx_eyelink_current_mode')
mx_eyelink_current_mode.mx_c.headers = ['<eyelink.h>','"mex.h"']
mx_eyelink_current_mode.bindo += []
mx_eyelink_current_mode.mx_c.code = \
"""
INT16 _main( void )
{
    return eyelink_current_mode();
}

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    mwSize td[2] = {1,1};
    double *status;
    
    /* Verify input arguments. */
    if(nrhs != 0 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs > 1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
            
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status = mxGetPr(plhs[0]);    
    *status = (double ) _main( ); 
    return;
}
"""

mx_eyelink_current_mode.mx_c.mdoc = \
"""function [ status ] = mx_eyelink_current_mode( )
%MX_EYELINK_CURRENT_MODE This function tests the current tracker mode, and 
% returns a set of flags based of what the mode is doing. The most useful flag
% using the EXPTSPPT toolkit is IN_USER_MENU to test if the EyeLink Abort menu
% has been activated.
%
% Returns:
% Set of bitflags that mark mode function: IN_DISCONNECT_MODE if disconnected. 
% IN_IDLE_MODE if off-line (Idle mode). IN_SETUP_MODE if in Setup-menu related 
% mode. IN_RECORD_MODE if tracking is in progress. IN_PLAYBACK_MODE if currently
% playing back data. IN_TARGET_MODE if in mode that requires a fixation target. 
% IN_DRIFTCORR_MODE if in drift-correction. IN_IMAGE_MODE if displaying grayscale 
% camera image. IN_USER_MENU if displaying Abort or user-defined menu.
%
% IN_DISCONNECT_MODE   16384
% IN_UNKNOWN_MODE   0
% IN_IDLE_MODE   1
% IN_SETUP_MODE   2
% IN_RECORD_MODE   4
% IN_TARGET_MODE   8
% IN_DRIFTCORR_MODE   16
% IN_IMAGE_MODE   32
% IN_USER_MENU   64
% IN_PLAYBACK_MODE   256
%
"""
mx_eyelink_current_mode.write_c()
mx_eyelink_current_mode.write_m()
mx_eyelink_current_mode.compile()
mx_eyelink_current_mode.write_sh()

